package org.dairy.farms.dao.hibernate;

import org.dairy.farms.dao.MedicineDAO;
import org.dairy.farms.dao.MedicineTypeDAO;
import org.dairy.farms.dao.generic.AbstractDAOImpl;
import org.dairy.farms.model.Medicine;
import org.dairy.farms.model.MedicineType;
import org.dairy.farms.model.Person;
import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: GDuggira
 * Date: 10/4/13
 * Time: 6:41 PM
 */
@Repository(value = "medicineTypeDao")
public class MedicineTypeDAOImpl extends AbstractDAOImpl<MedicineType, Long> implements MedicineTypeDAO {

    @Override
    public List<MedicineType> findByCheckupTypeId(Long checkupTypeId) {
        Criteria criteria = basePersistence.getSession().createCriteria(MedicineType.class);
        criteria.createCriteria("checkupTypes.checkup").add(Restrictions.eq("id",checkupTypeId));
        return criteria.list();
    }
}
